<?php
namespace Manage\Controller;
use Think\Controller;

/**
 * Class AdminPumpStationController
 * @package Manage\Controller
 * PC端泵站管理
 */
class AdminPumpStationController extends Controller {

    private $model_name = 'PumpingStation';
    private $number_field = 'ps_id';

    public function all_view(){
        $this->display('all_view');
    }

    public function get_all_facilities(){
        $model = D($this->model_name);
        $pump_model = D('PumpPump');
        $machinep_model = D('PumpMachine');
        $weather_model = D('WeatherchangeLog');
        $list = $model->select();
        $return_array = array();
        foreach($list as $v){
            $temp = array();
            $temp['id'] = $v['id'];
            $temp['name'] = $v['ps_name'];
            $temp['gps'] = $v['ps_point'];
            $temp['weather'] = $weather_model->get_last_one(1, $v['id']);
            $temp['a'] = $pump_model->q_s($v['id']);
            $temp['b'] = $machinep_model->q_s($v['id']);
            if($pump_model->q_s($v['id'])==-99&&$machinep_model->q_s($v['id'])==-99)
                $temp['status'] = 99;
            else if($pump_model->q_s($v['id'])==-1||$machinep_model->q_s($v['id'])==-1)
                $temp['status'] = -1;
            else
                $temp['status'] = 1;
            $return_array[] = $temp;
        }
        echo json_encode($return_array);
    }

    public function overview(){
        $id = I('get.id');
        $model = D($this->model_name);
        $pump_model = D('PumpPump');
        $machinep_model = D('PumpMachine');
        $cur = $model->queryObj($id, 'id');
        $pumps = $pump_model->queryField('ps_id', $id);
        $macs = $machinep_model->queryField('ps_id', $id);
        $this->assign('cur', $cur);
        $this->assign('pumps', $pumps);
        $this->assign('macs', $macs);
        $this->display();
    }

    public function index(){
        $duty_person = D('MobileAdmin')->getAll();
        $this->assign('duty_persons', $duty_person);
        $this->display();
    }

    public function get_all(){
        if(!I('get.gen')){
            $list = get_date_grid($this->model_name);
        }else{
            $map = array_merge(get_page_query_map(I('get.')), get_page_query_map(I('post.')));
            $page = max(I('get.page'), 1);
            $rows_num = get_kv_val('admin_page_list_num')?get_kv_val('admin_page_list_num'):I('get.rows');
            $list = D($this->model_name)->gen_search($map, $page, $rows_num);
        }
        echo json_encode($list);
    }

    public function add(){
        $model = D($this->model_name);
        if(IS_POST){
            $data = filterInput($_POST);
            $one = D($this->model_name)->queryObj($data[$this->number_field], $this->number_field);
            if($one){
                echo json_encode(array('status'=>-1,'msg'=>'标识码已经存在，请重新输入！'));
                exit;
            }
            $id = $model->addObj($data, 'id');
            echo json_encode(array('status'=>1, 'message'=>'', 'id'=>$id));
            return;
        }
    }

    public function edit(){
        $model = D($this->model_name);
        if(IS_POST){
            $post_data = filterInput($_POST);
            $model->save($post_data);
            echo json_encode(array('status'=>1, 'message'=>'','id'=>$post_data['id']));
            return;
        }
    }

    public function deleteArray(){
        $data = filterInput($_POST);
        $ids = $data['ids'];
        $model = D($this->model_name);
        $item = $model->deleteArray($ids);
        if($item){
            echo json_encode(array('status'=>1));
        }else{
            echo json_encode(array('status'=>0));
        }
    }

    public function list_index(){
        $duty_person = D('MobileAdmin')->getAll();
        $this->assign('duty_persons', $duty_person);
        $this->display('temp');
    }

    public function get_pump_station_tree(){
        $model = D($this->model_name);
        echo json_encode($model->get_pump_station_tree());
    }

    public function get_station_json(){
        $id = I('get.id');
        $obj = D($this->model_name)->queryObj($id, 'id');
        $obj['ps_opr_names'] = filter_id_to_ralname($obj['ps_opr']);
        echo $obj?json_encode($obj):json_encode(array('status'=> -1));
    }

    public function base_info(){
        $this->display();
    }

    public function waterpower(){
        $this->display();
    }

    public function pump_pump(){
        $this->display();
    }

    public function pump_pump_log(){
        $this->display('AdminPumpPump:log_index');
    }

    public function log_show_pump_index(){
        if(!I('get.cc'))
            $this->display();
        else
            $this->display('log_show_pump_nocheck_index');
    }

    public function pump_machine(){
        $this->display();
    }

    public function pump_machine_log(){
        $this->display('AdminPumpMachine:log_index');
    }

    public function log_show_machine_index(){
        if(!I('get.cc'))
            $this->display();
        else
            $this->display('log_show_machine_nocheck_index');
    }

    public function pump_waterele(){
        $this->display();
    }

    public function pump_waterele_log(){
        $this->display('AdminPumpWaterele:log_index');
    }

    public function log_show_waterele_index(){
        if(!I('get.cc'))
            $this->display();
        else
            $this->display('log_show_waterele_nocheck_index');
    }

    public function pump_water(){
        $this->display();
    }

    public function pump_water_log(){
        $this->display('AdminPumpWater:log_index');
    }

    public function log_show_water_index(){
        if(!I('get.cc'))
            $this->display();
        else
            $this->display('log_show_water_nocheck_index');
    }

    public function weather_log(){
        $this->display();
    }

    public function log_show_weather_index(){
        $this->display();
    }

    public function log_index(){
        if(!I('get.cc'))
            $this->display('log_opr');
        else
            $this->display('log_nocheck_opr');
    }

    public function bz_export_panel(){
        $this->display();
    }

    public function get_all_combox(){
        $list = D($this->model_name)->field('id,ps_name as name')->select();
        if(!I('get.change_all_text')){
            $list = stations_add_all_text($list);
        }
        echo json_encode($list);
    }

    public function get_all_combox_with_catg1(){
        $cat1 = I('get.ps_catg1');
        if(!$cat1){
            $this->get_all_combox();
            return;
        }
        $map['ps_catg1'] = array('eq', $cat1);
        $list = D($this->model_name)->where($map)->field('id,ps_name as name')->select();
        $list = stations_add_all_text($list);
        echo json_encode($list);
    }

    public function fy_just_see(){
        $ps_id = I('get.ps_id');
        $sta = 'Pump';
        $cur = D('PumpingStation')->queryObj($ps_id, 'id');
        $this->assign('cur', $cur);
        $pump_model = D($sta.'Pump');
        $this->assign('pumps', $pump_model->queryField('ps_id', $ps_id));
        $machine_model = D($sta.'Machine');
        $this->assign('macs', $machine_model->queryField('ps_id', $ps_id));
        $water_model = D($sta.'Water');
        $this->assign('waters', $water_model->queryField('ps_id', $ps_id));
        $waterele_model = D($sta.'Waterele');
        $this->assign('waterele', $waterele_model->queryField('ps_id', $ps_id));
        $collect_basin_model = D($sta.'CollectingBasin');
        $this->assign('cbs', $collect_basin_model->queryField('ps_id', $ps_id));
        $forebay_model = D($sta.'Forebay');
        $this->assign('fbs', $forebay_model->queryField('ps_id', $ps_id));
        $inlet_model = D($sta.'Inlet');
        $this->assign('inlets', $inlet_model->queryField('ps_id', $ps_id));
        $outletpipe_model = D($sta.'OutletPipe');
        $this->assign('outletpipes', $outletpipe_model->queryField('ps_id', $ps_id));
        $outletsum_model = D($sta.'OutletSum');
        $this->assign('outletsums', $outletsum_model->queryField('ps_id', $ps_id));
        $Valve_model = D($sta.'Valve');
        $this->assign('valves', $Valve_model->queryField('ps_id', $ps_id));
        $gate_model = D($sta.'Gate');
        $this->assign('gates', $gate_model->queryField('ps_id', $ps_id));
        $conveyor_model = D($sta.'Conveyor');
        $this->assign('conveyors', $conveyor_model->queryField('ps_id', $ps_id));
        $press_model = D($sta.'Press');
        $this->assign('presss', $press_model->queryField('ps_id', $ps_id));
        $hoist_model = D($sta.'Hoist');
        $this->assign('hoists', $hoist_model->queryField('ps_id', $ps_id));
        $charging_model = D($sta.'Charging');
        $this->assign('chargings', $charging_model->queryField('ps_id', $ps_id));
        $dynamo_model = D($sta.'Dynamo');
        $this->assign('dynamos', $dynamo_model->queryField('ps_id', $ps_id));
        $transformer_model = D($sta.'TransFormer');
        $this->assign('tfs', $transformer_model->queryField('ps_id', $ps_id));
        $this->display();
    }

    public function import(){
        header("Content-type: text/html; charset=utf-8");
        $filename = '.'.I('get.file_path');
        $start_row = 2;
        import("Org.Util.PHPExcel");
        import("Org.Util.PHPExcel.Reader.Excel5");
        $php_reader = new \PHPExcel_Reader_Excel5();
        $filename = file_zh_cn_icvon($filename);
        $php_excel = $php_reader->load($filename);

        $model = D('PumpingStation');
        $excel_stations = array();
        $no_in_excel_stations = array();
        for($sheet_index=0;$sheet_index<1;$sheet_index++){
            $currentSheet = $php_excel->getSheet($sheet_index);
            $allRow = $currentSheet->getHighestRow();
            for($currentRow = $start_row;$currentRow <= $allRow;$currentRow++){
                $map['ps_name'] = array('eq', $currentSheet->getCell('C'.$currentRow)->getValue());
                $one = $model->where($map)->find();
                if($one||$currentSheet->getCell('C'.$currentRow)->getValue()==''){
                    continue;
                }
                $station_data = array();
                $station_data['ps_id'] = $currentSheet->getCell('A'.$currentRow)->getValue();
                $station_data['ps_sysid'] = $currentSheet->getCell('B'.$currentRow)->getValue();
                $station_data['ps_name'] = $currentSheet->getCell('C'.$currentRow)->getValue();
                $station_data['ps_catg3'] = $currentSheet->getCell('D'.$currentRow)->getValue();
                $station_data['ps_catg1'] = $currentSheet->getCell('E'.$currentRow)->getValue();
                $station_data['ps_catg2'] = $currentSheet->getCell('F'.$currentRow)->getValue();
                $station_data['ps_scale'] = $currentSheet->getCell('G'.$currentRow)->getValue();
                $station_data['ps_addr'] = $currentSheet->getCell('H'.$currentRow)->getValue();
                $station_data['ps_point'] = $currentSheet->getCell('I'.$currentRow)->getValue();
                $station_data['ps_x'] = $currentSheet->getCell('J'.$currentRow)->getValue();
                $station_data['ps_y'] = $currentSheet->getCell('K'.$currentRow)->getValue();
                $station_data['ps_elev'] = $currentSheet->getCell('L'.$currentRow)->getValue();
                $station_data['ps_region'] = $currentSheet->getCell('M'.$currentRow)->getValue();
                $station_data['ps_area'] = $currentSheet->getCell('N'.$currentRow)->getValue();
                $station_data['ps_svc_scope'] = $currentSheet->getCell('O'.$currentRow)->getValue();
                $station_data['ps_svc_area'] = $currentSheet->getCell('P'.$currentRow)->getValue();
                $station_data['ps_p_num'] = $currentSheet->getCell('Q'.$currentRow)->getValue();
                $station_data['ps_bkp_num'] = $currentSheet->getCell('R'.$currentRow)->getValue();
                $station_data['ps_drain_amt'] = $currentSheet->getCell('S'.$currentRow)->getValue();
                $station_data['ps_dev_cap'] = $currentSheet->getCell('T'.$currentRow)->getValue();
                $station_data['ps_power_amt'] = $currentSheet->getCell('U'.$currentRow)->getValue();
                $station_data['ps_rwp_num'] = $currentSheet->getCell('V'.$currentRow)->getValue();
                $station_data['ps_bkrwp_num'] = $currentSheet->getCell('W'.$currentRow)->getValue();
                $station_data['ps_rwdrain_amt'] = $currentSheet->getCell('X'.$currentRow)->getValue();
                $station_data['ps_rwdrain_dsgn'] = $currentSheet->getCell('Y'.$currentRow)->getValue();
                $station_data['ps_rwdev_cap'] = $currentSheet->getCell('Z'.$currentRow)->getValue();
                $station_data['ps_rwpower_amt'] = $currentSheet->getCell('AA'.$currentRow)->getValue();
                $station_data['ps_sp_num'] = $currentSheet->getCell('AB'.$currentRow)->getValue();
                $station_data['ps_bksp_num'] = $currentSheet->getCell('AC'.$currentRow)->getValue();
                $station_data['ps_sdrain_amt'] = $currentSheet->getCell('AD'.$currentRow)->getValue();
                $station_data['ps_sdrain_dsgn'] = $currentSheet->getCell('AE'.$currentRow)->getValue();
                $station_data['ps_sdev_cap'] = $currentSheet->getCell('AF'.$currentRow)->getValue();
                $station_data['ps_spower_amt'] = $currentSheet->getCell('AG'.$currentRow)->getValue();
                $station_data['ps_ro_dsgn'] = $currentSheet->getCell('AH'.$currentRow)->getValue();
                $station_data['ps_rtp_dsgn'] = $currentSheet->getCell('AI'.$currentRow)->getValue();
                $station_data['ps_up_p'] = $currentSheet->getCell('AJ'.$currentRow)->getValue();
                $station_data['ps_down_p'] = $currentSheet->getCell('AK'.$currentRow)->getValue();
                $station_data['ps_to_riv'] = $currentSheet->getCell('AL'.$currentRow)->getValue();
                $station_data['ps_w_purific'] = $currentSheet->getCell('AM'.$currentRow)->getValue();
                $station_data['ps_int_num'] = $currentSheet->getCell('AN'.$currentRow)->getValue();
                $station_data['ps_out_num'] = $currentSheet->getCell('AO'.$currentRow)->getValue();
                $station_data['ps_sts'] = $currentSheet->getCell('AP'.$currentRow)->getValue();
                $station_data['ps_run_typ'] = $currentSheet->getCell('AQ'.$currentRow)->getValue();
                $station_data['ps_guard_typ'] = $currentSheet->getCell('AR'.$currentRow)->getValue();
                $station_data['ps_shift_sys'] = $currentSheet->getCell('AS'.$currentRow)->getValue();
                $station_data['ps_guard_num'] = $currentSheet->getCell('AT'.$currentRow)->getValue();
                $station_data['ps_ename'] = $currentSheet->getCell('AU'.$currentRow)->getValue();
                $station_data['ps_bulid_dept'] = $currentSheet->getCell('AV'.$currentRow)->getValue();
                $station_data['ps_dsgn_dept'] = $currentSheet->getCell('AW'.$currentRow)->getValue();
                $station_data['ps_constr_dept'] = $currentSheet->getCell('AX'.$currentRow)->getValue();
                $station_data['ps_surv_dept'] = $currentSheet->getCell('AY'.$currentRow)->getValue();
                $station_data['ps_prop_dept'] = $currentSheet->getCell('AZ'.$currentRow)->getValue();
                $station_data['ps_mt_dept'] = $currentSheet->getCell('BA'.$currentRow)->getValue();
                $station_data['ps_finish_dt'] = $currentSheet->getCell('BB'.$currentRow)->getValue();
                $station_data['ps_svc_dt'] = $currentSheet->getCell('BC'.$currentRow)->getValue();
                $station_data['ps_recon_dt'] = $currentSheet->getCell('BD'.$currentRow)->getValue();
                $station_data['ps_tel'] = $currentSheet->getCell('BE'.$currentRow)->getValue();
                $station_data['dev_gate'] = $currentSheet->getCell('BF'.$currentRow)->getValue();
                $station_data['dev_ipc'] = $currentSheet->getCell('BG'.$currentRow)->getValue();
                $station_data['dev_sec_sys'] = $currentSheet->getCell('BH'.$currentRow)->getValue();
                $station_data['dev_screemach'] = $currentSheet->getCell('BI'.$currentRow)->getValue();
                $station_data['dev_conv'] = $currentSheet->getCell('BJ'.$currentRow)->getValue();
                $station_data['dev_press'] = $currentSheet->getCell('BK'.$currentRow)->getValue();
                $station_data['dev_deodorizer'] = $currentSheet->getCell('BL'.$currentRow)->getValue();
                $station_data['dev_vent'] = $currentSheet->getCell('BM'.$currentRow)->getValue();
                $station_data['dev_hoist'] = $currentSheet->getCell('BN'.$currentRow)->getValue();
                $station_data['dev_gen'] = $currentSheet->getCell('BO'.$currentRow)->getValue();
                $station_data['dev_valve'] = $currentSheet->getCell('BP'.$currentRow)->getValue();
                $station_data['dev_penstock'] = $currentSheet->getCell('BQ'.$currentRow)->getValue();
                $station_data['ps_groprc_dl'] = $currentSheet->getCell('BR'.$currentRow)->getValue();
                $station_data['ps_mapno'] = $currentSheet->getCell('BS'.$currentRow)->getValue();
                $station_data['ps_datasrc'] = $currentSheet->getCell('BT'.$currentRow)->getValue();
                $station_data['ps_data_dt'] = $currentSheet->getCell('BU'.$currentRow)->getValue();
                $station_data['ps_rpt_dept'] = $currentSheet->getCell('BV'.$currentRow)->getValue();
                $station_data['ps_rpt_dt'] = $currentSheet->getCell('BW'.$currentRow)->getValue();
                $model->add($station_data);
            }
        }
        echo '导入完成';
    }

    public function export(){
        header("Content-type: text/html; charset=utf-8");
        import("Org.Util.PHPExcel");
        import("Org.Util.PHPExcel.Reader.Excel5");
        import("Org.Util.PHPExcel.Writer.Excel5");
        import("Org.Util.PHPExcel.IOFactory.php");
        $temp_file = './exportexcel/station.xls';
        $php_reader = new \PHPExcel_Reader_Excel5();
        $filename = file_zh_cn_icvon($temp_file);
        if(!$php_reader->canRead($filename)){
            echo '无法识别的Excel文件！';
            return false;
        }
        $php_excel = $php_reader->load($filename);
        $currentSheet = $php_excel->getSheet(0);
        $model = D('PumpingStation');
        $list = $model->getAll();
        $currentRow = 2;
        foreach($list as $station_data){
             $currentSheet->setCellValue('A'.$currentRow, $station_data['ps_id']);
             $currentSheet->setCellValue('B'.$currentRow, $station_data['ps_sysid']);
             $currentSheet->setCellValue('C'.$currentRow, $station_data['ps_name']);
             $currentSheet->setCellValue('D'.$currentRow, pump_station_base_types_option($station_data['ps_catg3'], false));
             $currentSheet->setCellValue('E'.$currentRow, pump_station_types_option($station_data['ps_catg1'], false));
             $currentSheet->setCellValue('F'.$currentRow, pump_station_types_second_option($station_data['ps_catg2'], false));
             $currentSheet->setCellValue('G'.$currentRow, pump_station_scope_option($station_data['ps_scale'], false));
             $currentSheet->setCellValue('H'.$currentRow, $station_data['ps_addr']);
             $currentSheet->setCellValue('I'.$currentRow, $station_data['ps_point']);
             $currentSheet->setCellValue('J'.$currentRow, $station_data['ps_x']);
             $currentSheet->setCellValue('K'.$currentRow, $station_data['ps_y']);
             $currentSheet->setCellValue('L'.$currentRow, $station_data['ps_elev']);
             $currentSheet->setCellValue('M'.$currentRow, pump_station_area_option($station_data['ps_region'], false));
             $currentSheet->setCellValue('N'.$currentRow, $station_data['ps_area']);
             $currentSheet->setCellValue('O'.$currentRow, $station_data['ps_svc_scope']);
             $currentSheet->setCellValue('P'.$currentRow, $station_data['ps_svc_area']);
             $currentSheet->setCellValue('Q'.$currentRow, $station_data['ps_p_num']);
             $currentSheet->setCellValue('R'.$currentRow, $station_data['ps_bkp_num']);
             $currentSheet->setCellValue('S'.$currentRow, $station_data['ps_drain_amt']);
             $currentSheet->setCellValue('T'.$currentRow, $station_data['ps_dev_cap']);
             $currentSheet->setCellValue('U'.$currentRow, $station_data['ps_power_amt']);
             $currentSheet->setCellValue('V'.$currentRow, $station_data['ps_rwp_num']);
             $currentSheet->setCellValue('W'.$currentRow, $station_data['ps_bkrwp_num']);
             $currentSheet->setCellValue('X'.$currentRow, $station_data['ps_rwdrain_amt']);
             $currentSheet->setCellValue('Y'.$currentRow, $station_data['ps_rwdrain_dsgn']);
             $currentSheet->setCellValue('Z'.$currentRow, $station_data['ps_rwdev_cap']);
             $currentSheet->setCellValue('AA'.$currentRow, $station_data['ps_rwpower_amt']);
             $currentSheet->setCellValue('AB'.$currentRow, $station_data['ps_sp_num']);
             $currentSheet->setCellValue('AC'.$currentRow, $station_data['ps_bksp_num']);
             $currentSheet->setCellValue('AD'.$currentRow, $station_data['ps_sdrain_amt']);
             $currentSheet->setCellValue('AE'.$currentRow, $station_data['ps_sdrain_dsgn']);
             $currentSheet->setCellValue('AF'.$currentRow, $station_data['ps_sdev_cap']);
             $currentSheet->setCellValue('AG'.$currentRow, $station_data['ps_spower_amt']);
             $currentSheet->setCellValue('AH'.$currentRow, $station_data['ps_ro_dsgn']);
             $currentSheet->setCellValue('AI'.$currentRow, $station_data['ps_rtp_dsgn']);
             $currentSheet->setCellValue('AJ'.$currentRow,$station_data['ps_up_p'] );
             $currentSheet->setCellValue('AK'.$currentRow, $station_data['ps_down_p']);
             $currentSheet->setCellValue('AL'.$currentRow, $station_data['ps_to_riv']);
             $currentSheet->setCellValue('AM'.$currentRow, $station_data['ps_w_purific']);
             $currentSheet->setCellValue('AN'.$currentRow, $station_data['ps_int_num']);
             $currentSheet->setCellValue('AO'.$currentRow, $station_data['ps_out_num']);
             $currentSheet->setCellValue('AP'.$currentRow, pump_station_status_option($station_data['ps_sts'], false));
             $currentSheet->setCellValue('AQ'.$currentRow, ps_run_typ($station_data['ps_run_typ'], false));
             $currentSheet->setCellValue('AR'.$currentRow, ps_guard_typ($station_data['ps_guard_typ'], false));
             $currentSheet->setCellValue('AS'.$currentRow, ps_shift_sys($station_data['ps_shift_sys'], false));
             $currentSheet->setCellValue('AT'.$currentRow,  $station_data['ps_guard_num']);
             $currentSheet->setCellValue('AU'.$currentRow, $station_data['ps_ename']);
             $currentSheet->setCellValue('AV'.$currentRow, $station_data['ps_bulid_dept']);
             $currentSheet->setCellValue('AW'.$currentRow, $station_data['ps_dsgn_dept']);
             $currentSheet->setCellValue('AX'.$currentRow, $station_data['ps_constr_dept']);
             $currentSheet->setCellValue('AY'.$currentRow, $station_data['ps_surv_dept']);
             $currentSheet->setCellValue('AZ'.$currentRow, $station_data['ps_prop_dept']);
             $currentSheet->setCellValue('BA'.$currentRow, $station_data['ps_mt_dept']);
             $currentSheet->setCellValue('BB'.$currentRow, $station_data['ps_finish_dt'] );
             $currentSheet->setCellValue('BC'.$currentRow, $station_data['ps_svc_dt']);
             $currentSheet->setCellValue('BD'.$currentRow, $station_data['ps_recon_dt']);
             $currentSheet->setCellValue('BE'.$currentRow, $station_data['ps_tel']);
             $currentSheet->setCellValue('BF'.$currentRow, is_have($station_data['dev_gate'], false));
             $currentSheet->setCellValue('BG'.$currentRow, is_have($station_data['dev_ipc'], false));
             $currentSheet->setCellValue('BH'.$currentRow, is_have($station_data['dev_sec_sys'], false));
             $currentSheet->setCellValue('BI'.$currentRow, is_have($station_data['dev_screemach'], false));
             $currentSheet->setCellValue('BJ'.$currentRow, is_have($station_data['dev_conv'], false));
             $currentSheet->setCellValue('BK'.$currentRow, is_have($station_data['dev_press'], false));
             $currentSheet->setCellValue('BL'.$currentRow, is_have($station_data['dev_deodorizer'], false));
             $currentSheet->setCellValue('BM'.$currentRow, is_have($station_data['dev_vent'], false));
             $currentSheet->setCellValue('BN'.$currentRow, is_have($station_data['dev_hoist'], false));
             $currentSheet->setCellValue('BO'.$currentRow, is_have($station_data['dev_gen'], false));
             $currentSheet->setCellValue('BP'.$currentRow, is_have($station_data['dev_valve'], false));
             $currentSheet->setCellValue('BQ'.$currentRow, is_have($station_data['dev_penstock'], false));
             $currentSheet->setCellValue('BR'.$currentRow, $station_data['ps_groprc_dl']);
             $currentSheet->setCellValue('BS'.$currentRow, $station_data['ps_mapno']);
             $currentSheet->setCellValue('BT'.$currentRow, ps_datasrc($station_data['ps_datasrc'], false));
             $currentSheet->setCellValue('BU'.$currentRow, $station_data['ps_data_dt']);
             $currentSheet->setCellValue('BV'.$currentRow, $station_data['ps_rpt_dept']);
             $currentSheet->setCellValue('BW'.$currentRow, $station_data['ps_rpt_dt']);
            $currentRow++;
        }
        $currentSheet->getStyle('A1:BW'.$currentRow)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        $currentSheet->getStyle('A1:BW'.$currentRow)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
        $currentSheet->getStyle('A1:BW'.$currentRow)->getBorders()->getAllBorders()->setBorderStyle(\PHPExcel_Style_Border::BORDER_THIN);
        $php_writer = new \PHPExcel_Writer_Excel5($php_excel);
        ob_end_clean();//清除缓冲区,避免乱码
        header('Content-Type: application/vnd.ms-excel');
        header("Content-Disposition: attachment;filename=泵站.xls");
        header('Cache-Control: max-age=0');
        $php_writer->save('php://output');
    }
}